<%--
  Created by IntelliJ IDEA.
  User: 14364
  Date: 2023/1/4
  Time: 11:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/bootstrap-5.1.3-dist/css/bootstrap.css">
    <script type="text/javascript" src="/static/bootstrap-5.1.3-dist/js/bootstrap.js"></script>
    <title>他的帖子</title>
</head>

<style>
    .back{
        position: absolute;
        font-size: 26px;
        top:30px;
        left:40px;
        text-decoration: none;
        color: #000;
        font-weight: bold;
    }
    .back:hover{
        color: #000;
    }

    h2{
        text-align: center;
        margin-top: 15px;
    }

    .card{
        width: 1400px;
        height: 700px;
        background-color: #fffdfd;
        border-radius: 30px;
        border: none;
        box-shadow: 5px 5px 10px #adabab;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        margin: auto;
    }

    .operate {
        padding: 20px 40px;
    }

    .operate button {
        border: solid;
        width: 150px;
    }

    table {
        text-align: center;
        vertical-align: middle !important;
        word-wrap:break-all;
        word-break:break-all;
        table-layout:fixed;

        width: 90% !important;
        margin-left: 80px;

    }

    .page {
        height: 50px;
        /*width: 1270px;*/
        /*margin-left: 1400px;*/
        position: fixed;
        bottom: 180px;
        right: 200px;
    }
</style>

<body>
<a href="${pageContext.request.contextPath}/post_list" class="back">
    <span><</span>返回</a>
<h2>他的帖子</h2>
<div class="card">
    <div class="search">
        <form  class="operate" method="get" action="ones_post_list">
            <input name="method" value="query" class="input-text form-control" type="hidden">
            <div class="row">
                <div class="col-sm-1" >
                    <label style="margin-top: 10px">查询帖子</label>
                </div>
                <div class="col-sm-4"  >
                    <input class="form-control" placeholder="请输入内容" name="postKeys" type="text" value="${postKey}" autocomplete="on">
                </div>
                <div class="col-sm-3">
                    <input value="查 询" type="submit" class="btn btn-outline-secondary" id="searchbutton">
                </div>
            </div>

            <input type="hidden" name="page" value="1"/>
            <input type="hidden" name="userid" value="${user.id}">

        </form>
    </div>

    <table id="test" class="table table-bordered table-striped">
        <colgroup>
            <col width="100">
            <col width="200">
            <col width="150">
            <col width="150">
        </colgroup>
        <thead>
        <tr>
            <th>发帖人头像</th>
            <th>发帖人</th>
            <th>主题</th>
            <th>时间</th>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${posts}" var="post" varStatus="s">
            <tr>
                <td>
                    <img src="${pageContext.request.contextPath}/display?photo=${user.photo}" style="width: 100px;height: 100px">
                </td>
                <td>${user.username}</td>
                <td><a href="commentList?pid=${post.id}"} class="btn-outline-secondary">${post.title}</a></td>
                <td>${post.date}</td>
            </tr>
        </c:forEach>
        </tbody>
    </table>

    <div class="page">
        <nav aria-label="Page navigation example">
            <ul class="pagination justify-content-between">
                <c:if test="${pageInfo.isLast && falg == null}">
                    <li><a href="ones_post_list?page=${pageInfo.pageIndex-1}&postKeys=${postKey}&userid=${user.id}" class="page-link"><span
                            aria-hidden="true">&larr;</span> 上一页</a></li>
                </c:if>
                <c:if test="${pageInfo.isNext && falg == null}">
                    <li><a href="ones_post_list?page=${pageInfo.pageIndex+1}&postKeys=${postKey}&userid=${user.id}" class="page-link">下一页 <span
                            aria-hidden="true">&rarr;</span></a></li>
                </c:if>

            </ul>
            <span>第 ${pageInfo.pageIndex} 页/共 ${pageInfo.sumCount} 页</span>
        </nav>
    </div>


</div>

</body>
</html>